<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="/red/lib/reset.css">
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/red/lib/all.css">
    <link rel="stylesheet" href="/hyqcss/public.css">

    <style type="text/css">
        body{
            background: #e9e9e9;
        }
        /*公共头部带搜索*/
        .public_container{
            margin: 20px;
            background: #fff;
        }
        .public_title_container{
            height: 54px;
            padding: 0 20px;
            font-size: 14px;
            display: flex;
            align-items: center;
            background: #f9f9f9;
            border-bottom: 1px solid #f0f0f0;
        }
        .public_title_container a{
            margin-right: 30px;
            height: 54px;
            line-height: 54px;
            cursor: pointer;
        }
        .public_title_active{
            color: #1E9FFF;
            border-bottom: 1px solid #1E9FFF;
        }
        .public_buttonSearch_container{
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px;
            background: #fff;
        }
        .public_buttonSearch_containers{
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px;
            background: #fff;
        }
        .public_Search_container{
            position: relative;
        }
        .public_Search_container input{
            width: 240px;
            height: 32px;
            border: 1px solid #d9d9d9;
        }
        .public_Search_container i{
            position: absolute;
            bottom: 6px;
            right: 10px;
            cursor: pointer;
        }
        /*公共头部带搜索 end*/
        .public_table_container{
            padding: 0 20px 20px 20px;
        }
        .public_Search_content{
            display: flex;
        }
        .public_Search_content a{
            color: #fff;
            background-color: #1E9FFF;
            text-shadow: 0 -1px 0 rgba(0,0,0,.12);
            height: 24px;
            padding: 4px 15px;
            font-size: 14px;
            border-radius: 2px;
            display: flex;
            cursor: pointer;
            align-items: center;
        }
        .public_SearchSelect_content input{
            height: 32px;
        }
        .public_SearchSelect_content{
            margin-right: 10px;
        }
        .public_buttonSearch_content{
            display: flex;
        }
        .public_buttonSearch_content a{
            color: #fff;
            background-color: #1E9FFF;
            text-shadow: 0 -1px 0 rgba(0,0,0,.12);
            height: 24px;
            padding: 4px 15px;
            font-size: 14px;
            border-radius: 2px;
            display: flex;
            cursor: pointer;
            align-items: center;
        }
        .public_buttonSearch_content span{
            color: rgba(0,0,0,0.65);
            background-color: #fff;
            height: 32px;
            padding: 4px 15px;
            font-size: 14px;
            border-radius: 2px;
            display: flex;
            align-items: center;
            border: 1px solid #d9d9d9;
            margin-left: 10px;
        }
        .public_buttonSearch_daoruhuashu{
            margin-left: 10px;
        }
    </style>
</head>
<body>
<!-- 顶部提示框 开始 -->
    <div class="public_tipSetting_contaienr">
        <div class="public_tipSetting_content">
            <p>使用红包需先在微信支付后台开通企业付款到零钱功能，本功能可以实现使用企业微信向个人或微信群发放红包。</p>
            <a href="https://support.qq.com/products/174823/faqs/83871" target="_blank">查看教程</a>
            <svg t="1599462804099" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8813" width="15" height="15"><path d="M512 102.4a409.6 409.6 0 1 0 409.6 409.6 409.6 409.6 0 0 0-409.6-409.6z m181.248 518.144a51.2 51.2 0 0 1-72.704 72.704L512 584.192l-108.544 109.056a51.2 51.2 0 0 1-72.704-72.704L439.808 512 330.752 403.456a51.2 51.2 0 0 1 72.704-72.704L512 439.808l108.544-109.056a51.2 51.2 0 0 1 72.704 72.704L584.192 512z" fill="" p-id="8814"></path></svg>
        </div>
    </div>
    <!-- 顶部提示框 结束 -->
<div class="main">
    <!-- <div class="left-nav"></div> -->
    <div class="" style="width: 100%;">
        <!-- <div class="top-nav"></div> -->
        <div class="" style="background: #e9e9e9; padding: 20px;">
            <div class="public_content">
                <div class="public_title_container">
                    <a class="public_title_active navigation_1">红包模板</a>
                    <a class="navigation_2">数据统计</a>
                    <a class="navigation_3">参数配置</a>
                    <a class="navigation_4">红包配置</a>
                </div>
                <div class="public_buttonSearch_container">
                    <div class="public_buttonSearch_content">
                        <a class="showmoeny">创建红包模板</a>
                    </div>
                    
                    <div class="public_Search_content">
                        <a class="showuser">可用员工范围</a>
                        <a class="public_buttonSearch_daoruhuashu showline">红包限额</a>
                    </div>
                    
                </div>
            </div>

            <!-- <div class="header" style="height: 38px;">
                <div class="left-header tab-nav">
                    <span class="active">红包模板</span>
                    <span>数据统计</span>
                </div>
                <div class="right-header tab-body2">
                    <div>
                        <div class="layui-btn-group">
                            <button type="button" class="layui-btn layui-btn-normal showmoeny">
                                <i class="layui-icon">&#xe608;</i> 创建红包模板
                            </button>
                            <button type="button" class="layui-btn layui-btn-normal showuser">
                                <i class="layui-icon">&#xe66f;</i> 可用员工范围
                            </button>
                            <button type="button" class="layui-btn layui-btn-normal showline">
                                <i class="layui-icon">&#xe659;</i> 红包限额
                            </button>
                        </div>
                    </div>
                    <div></div>
                </div>
            </div> -->
            <div class="container tab-body" style="padding-top: 0;">
                <div class="nav_1">
                    <table class="layui-table" lay-skin="line" style="margin-top: 0;">
                        <colgroup>
                            <col width="10%">
                            <col width="15%">
                            <col width="20%">
                            <col width="15%">
                            <col width="15%">
                            <col width="25%">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>红包金额</th>
                            <th>发送次数</th>
                            <!-- <th>创建人</th> -->
                            <th>创建时间</th>
                            <th>使用场景</th>
                            <th>状态</th>
                            <th style="text-align: right">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {loop $user as $users}
                        <tr>
                            <td>{$users->hbprice}</td>
                            <td>{$users->number}</td>
                            <!-- <td>
                                <div class="tx-temp">
                                    <img src="{$users->img}" alt="">
                                    <p>{$users->cyname}</p>
                                </div>
                            </td> -->
                            <td>{$users->ctime}</td>
                            <td>{$users->scenario}</td>
                            <td>
                                {if $users->status==1}<span class="table-public-label">使用中</span>{else}<span class="table-public-label">停用</span>{/if}
                            </td>
                            <td class="text-right">
                                <span class="table-public-btn" onclick="ting('{$users->id}')">停用</span>
                                <span class="table-public-btn" onclick="uphb('{$users->id}')">修改</span>
                                <span class="table-public-btn" onclick="dehb('{$users->id}')">删除</span>
                            </td>
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                </div>
                <div class="nav_2" style="display: none;padding-top: 20px;">
                    <div class="number-row">
                        <div class="number-item">
                            <h1>{$price}</h1>
                            <p>今日发送总金额</p>
                        </div>
                        <div class="number-item">
                            <h1>{$prices}</h1>
                            <p>今日领取总金额</p>
                        </div>
                        <div class="number-item">
                            <h1>{$sy_price}</h1>
                            <p>今日待领取总金额</p>
                        </div>
                    </div>
                    <div class="mt select-row">
                        <div class="select-item">
                            <span>发送记录：</span>
                            <div class="select-right">
                                <label for="a2">
                                    <input style="margin: 0;flex: 0 0 25px;" onchange="sab(this)" type="radio" id="a2" value="0" name="gu" checked> 客户记录
                                </label>
                                <label for="a3">
                                    <input onchange="sab(this)" style="margin: 0;flex: 0 0 25px" type="radio" id="a3" name="gu" value="1"> 客户群记录
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="mt select-row">
                        <div class="select-item">
                            <span>搜索客户：</span>
                            <div class="select-right">
                                <div class="search-input">
                                    <input type="text" placeholder="请输入客户" id="soukh"  name="testone"> <i class="layui-icon">&#xe615;</i>
                                </div>
                            </div>
                        </div>
                        <div class="select-item">
                            <span>选择员工：</span>
                            <div class="select-right">
                                <div class="search-input">
                                    <select name="testone" id="testone">   
                                        <option value=""></option>
                                        {loop $name_bb as $name_aa}
                                        <option value="{$name_aa}">{$name_aa}</option>
                                        {/loop}
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="select-item">
                            <span>发送金额：</span>
                            <div class="select-right">
                                <div class="search-input">
                                    <select name="testone" id="price_one">
                                        <option value=""></option>
                                        {loop $price_bb as $price_aa}
                                        <option value="{$price_aa}">{$price_aa}</option>
                                        {/loop}
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="select-item">
                            <span>领取状态：</span>
                            <div class="select-right">
                                <div class="search-input">
                                    <select name="testone" id="number_one">
                                        <option value=""></option>
                                        <option value="1">已领取</option>
                                        <option value="2">未领取</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="mt select-row">
                        <div class="select-item">
                            <span>发送时间：</span>
                            <div class="select-right" >
                                <div class="search-input">
                                     <input type="text" class="layui-input" id="time" style="border: none;"> <i class="layui-icon" onclick="blers()">&#xe615;</i>
                                </div>
                            </div>
                        </div>
                        <div class="select-item">
                            <span>设置：</span>
                            <div class="select-right">
                                <!-- <button class="layui-btn layui-btn-sm layui-btn-normal">导出数据</button> -->
                                <button class="layui-btn layui-btn-sm layui-btn-normal" onclick="chong()">重置</button>
                            </div>
                        </div>
                    </div>
                    <div class="table-select">
                        <table class="layui-table mt" lay-skin="line">
                            <colgroup>
                                <col width="15%">
                                <col width="15%">
                                <col width="15%">
                                <col width="15%">
                                <col width="15%">
                                <col width="15%">
                                <col width="20%">
                            </colgroup>
                            <thead>
                            <tr>
                                <th>发送金额</th>
                                <th>发送员工</th>
                                <th>发送时间</th>
                                <th>领取客户</th>
                                <th>领取状态</th>
                                <th>领取时间</th>
                                <th style="text-align: right">操作</th>
                            </tr>
                            </thead>
                            <tbody id="trssse">
                            {loop $list_one as $value_one}
                            <tr>
                                <td>{$value_one->price}</td>
                                <td>
                                    <div class="tx-temp">
                                        <img src="{$value_one->user->avatar}" alt="">
                                        <p>{$value_one->user->name}</p>
                                    </div>
                                </td>
                                <td><?php echo date('Y-m-d H:i:s',$value_one->ctime)?></td>
                                <td>
                                    <div class="tx-temp">
                                        {if $value_one->list->id}
                                        <img src="{$value_one->list->avatar}" alt="">
                                        <p>{$value_one->list->name}</p>
                                        {else}
                                        暂无领取记录
                                        {/if}
                                    </div>
                                </td>
                                <td>{if !$value_one->sy_number}已领取{else}未领取{/if}</td>
                                <td>{if $value_one->lists->ctime} <?php echo date('Y-m-d H:i:s',$value_one->lists->ctime)?> {else}--{/if}</td>
                                <td style="text-align: right">
                                    <span class="table-public-btn" class="href" onclick="customer_info({$value_one->list->id})">客户详情</span>
                                </td>
                            </tr>
                            {/loop}
                            </tbody>
                        </table>
                        <table style="display: none" class="layui-table mt" lay-skin="line">
                            <colgroup>
                                <col width="10%">
                                <col width="15%">
                                <col width="15%">
                                <col width="15%">
                                <col width="15%">
                                <col width="15%">
                                <col width="25%">
                            </colgroup>
                            <thead>
                            <tr>
                                <th>发送金额</th>
                                <th>发送员工</th>
                                <th>发送时间</th>
                                <!-- <th>领取客户群</th> -->
                                <th>领取进度</th>
                                <th>领取状态</th>
                                <th style="text-align: right">操作</th>
                            </tr>
                            </thead>
                            <tbody id="trssses">
                            {loop $list_tow as $value_tow}
                            <tr>
                                <td>{$value_tow->price}</td>
                                <td>
                                    <div class="tx-temp">
                                        <img src="{$value_tow->user->avatar}" alt="">
                                        <p>{$value_tow->user->name}</p>
                                    </div>
                                </td>
                                <td><?php echo date('Y-m-d H:i:s',$value_tow->ctime)?></td>
                                <!-- <td>
                                    <div class="tx-temp">
                                        <img src="img/tx.jpg" alt="">
                                        <p>王强 <span>(15)</span></p>
                                    </div>
                                </td> -->
                                <td>{$value_tow->sy_number}/{$value_tow->number}</td>
                                <td>{if $value_tow->sy_number<1}已领取完{else}领取进行中{/if}</td>
                                <td style="text-align: right">
                                    <span class="href" onclick="showinfo('{$value_tow->id}')">领取详情</span>
                                    <!-- <span class="href">客户群详情</span> -->
                                </td>
                            </tr>
                            {/loop}
                            </tbody>
                        </table>
                    </div>

                </div>

                <div class="nav_3" style="display:none; padding-top: 20px;">
                    <!-- <form class="layui-form mt" action="update_confing.html"> -->
                        <div class="layui-form-item">
                            <label class="layui-form-label">商户号<span style="color:red;">*</span></label>
                            <div class="layui-input-block">
                                <input type="text" id="mchid" required lay-verify="required" placeholder="请填写正确的mchid" autocomplete="off" class="layui-input" value="{$confing->mchid}">
                            </div>
                        </div>
                        <!-- <div class="layui-form-item">
                            <label class="layui-form-label">Appsecret<span style="color:red;">*</span></label>
                            <div class="layui-input-block">
                                <input type="text" id="appKey" required lay-verify="required" placeholder="请填写正确的appKey" autocomplete="off" class="layui-input" value="{$confing->appKey}">
                            </div>
                        </div> -->
                        <div class="layui-form-item">
                            <label class="layui-form-label">API密钥<span style="color:red;">*</span></label>
                            <div class="layui-input-block">
                                <input type="text" id="apiKey" required lay-verify="required" placeholder="请填写正确的apiKey" autocomplete="off" class="layui-input" value="{$confing->apiKey}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">企业证书1<span style="color:red;">*</span></label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn layui-btn-normal" id="test1" onclick="falses(); ">上传企业证书</button>
                                    <input type="text"  id="demospan1" required lay-verify="required" autocomplete="off" class="layui-input" style="border:none" disabled value="{$confing->cert_one}">
                                    <input type="file" hidden id="filkes"/>
                                </div>
                            </div>
                        </div> 
                        <div class="layui-form-item">
                            <label class="layui-form-label">企业证书2<span style="color:red;">*</span></label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button"  class="layui-btn layui-btn-normal" id="test2" onclick="falsesone(); ">上传企业证书</button>
                                    <input type="text" id="demospan2" required lay-verify="required" autocomplete="off" class="layui-input" style="border:none" disabled value="{$confing->cert_tow}">
                                    <input type="file" hidden id="filkeone"/>
                                </div>
                            </div>
                        </div> 
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn layui-btn-normal" id="update_confing">修改配置</button>
                            </div>
                        </div>
                    <!-- </form> -->
                </div>
                <div class="nav_4" style="display:none; padding-top: 20px;">
                  <div class="public_content">
                        <div class="public_title_container">
                            <!--<a href="/Addons/QyWechat/Admin/Reply/quick_reply_steps.html">应用配置</a>
                            <a href="/Addons/CustomerPortrait/Admin/Portrait/index.html">客户画像</a>-->
                            <a href="/Addons/CustomerQrcode/Admin/CustomerQrcode/index.html" class="public_title_active">红包</a>
                        </div>
                        <div class="public_buttonSearch_containers">
                            <div class="public_buttonSearch_content">
                                <!-- <input type="text" id="toolbarUrl" value="{$toolbarUrl}" style=" position: fixed;  width: 5px;    top: -6px;   height: 6px;" readonly /> -->
                                <span class="layui-btn layui-btn-primary" onclick="copyToClip('{$toolbarUrl}')">复制工具栏URL</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="moneys" style="display: none">
<!--     <div class="tips">
        提示：请填写真实信息
    </div> -->
    <form class="layui-form mt" action="upload_hb.html" enctype="multipart/form-data">
        <div class="layui-form-item">
            <label class="layui-form-label">红包金额</label>
            <div class="layui-input-block">
                <input type="text" name="prices" id="prices" required lay-verify="required"  placeholder="请输入标题" autocomplete="off"
                       class="layui-input">
                <input type="hidden" name="ids" id="ids" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">企业名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" required lay-verify="required" id="names"  placeholder="请输入标题" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <!-- <div class="layui-form-item">
            <label class="layui-form-label">当前场景</label>
            <div class="layui-input-block">
                <input type="text"required lay-verify="required" id="writess" placeholder="请输入标题" autocomplete="off"
                       class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">使用场景</label>
            <div class="layui-input-block">
                <input type="checkbox" name="write" id="write" title="发送单个客户" >
                <input type="checkbox" name="read"  id="read" title="发送客户群" >
            </div>
        </div> -->
        <!-- <div class="tips">
            提示：上传你的专属封面
        </div>
        <div class="layui-form-item mt">
            <label class="layui-form-label">企业logo</label>
            <div class="layui-input-block">
                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="test1" onclick="uploads('{$v.master_order_sn}'); ">上传图片</button>
                    <input type="file" hidden id="{$v.master_order_sn}" />
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="demo1" >
                        <input type="hidden" id="demo2" name="file" />
                        <p id="demoText"></p>
                    </div>
                </div>
            </div>
        </div> -->
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">修改</button>
            </div>
        </div>
    </form>
</div>






<div id="money" style="display: none">
    <!-- <div class="tips">
        提示：请填写真实信息
    </div> -->
    <form class="layui-form mt" action="add_envelopes.html" enctype="multipart/form-data">
        <div class="layui-form-item">
            <label class="layui-form-label">红包金额</label>
            <div class="layui-input-block">
                <input type="text" name="price" required lay-verify="required" placeholder="请输入标题" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">企业名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" required lay-verify="required" placeholder="请输入标题" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <!-- <div class="layui-form-item">
            <label class="layui-form-label">使用场景</label>
            <div class="layui-input-block">
                <input type="checkbox" name="write" title="发送单个客户">
                <input type="checkbox" name="read" title="发送客户群">
            </div>
        </div> -->
        <!-- <div class="tips">
            提示：上传你的专属封面
        </div>
        <div class="layui-form-item mt">
            <label class="layui-form-label">企业logo</label>
            <div class="layui-input-block">
                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="test1" onclick="uploads('{$v.master_order_sn}'); ">上传图片</button>
                    <input type="file" hidden id="{$v.master_order_sn}" />
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="demo1s" >
                        <input type="hidden" id="demo2s" name="file" />
                        <p id="demoText"></p>
                    </div>
                </div>
            </div>
        </div> -->
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">创建</button>
            </div>
        </div>
    </form>
</div>

<div id="user" style="display: none">
    <div class="tips">
        提示
    </div>
    <div class="layui-form-item mt">
        <label class="layui-form-label">使用成员</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn layui-btn-primary" id="but">
                <i class="layui-icon">&#xe608;</i> 添加成员
            </button>
        </div>
    </div>
    
    <div class="mb-row">
         {loop $userlist as $list}
        <div class="mb">
            <div class="tx-temp">
                <img src="{$list->avatar}" alt="">
                <p> {$list->name}</p>
            </div>
            <span><i class="layui-icon" onclick="checks('{$list->id}')">&#x1006;</i></span>
        </div>
        {/loop}
    </div>
</div>
<div class="mb-row" id="butyg"style="display: none">
      {loop $users_list as $lists}
        <div class="mb">
            <span style="padding-right: 10px;"><input type="checkbox" name="test" value="{$lists['id']}"></span>
            <div class="tx-temp">
                <img src="{$lists['avatar']}" alt="">
                <p> {$lists['name']}</p>
            </div>
        </div>
    {/loop}
    <div style="width: 540px; margin: 0;">
      <button type="button" class="layui-btn layui-btn-fluid layui-btn-normal" onclick="check()">确认添加</button>
    </div>
</div>

<div id="line" style="display: none">
    <div class="tips">
        提示：输入数值之后点击其他位置以保存，不能一致
    </div>
    <table class="layui-table">
        <colgroup>
            <col width="150">
            <col width="200">
        </colgroup>
        <thead>
        <tr>
            <th>员工</th>
            <th>每日限额</th>
        </tr>
        </thead>
        <tbody>
        {loop $userlist as $listse}
        <tr>
            <td>
                <div class="tx-temp">
                    <img src="{$listse->avatar}" alt="">
                    <p>{$listse->name}</p>
                </div>
            </td>
            <td>
                <div class="layui-input-block">
                    <input type="text" id="usernames_{$listse->id}" lay-verify="required" lay-reqtext="用户名是必填项，岂能为空？" value="{$user_money[$listse->id]}" placeholder="请输入" autocomplete="off" class="layui-input" onblur="select_limit('{$listse->id}')">
                </div>
            </td>
        </tr>
         {/loop}
        </tbody>
    </table>
</div>
<div id="info" style="display: none">
    <div class="tips">
        红包 发送时间:2020-09-22 00:48
    </div>
    <div class="number-row mt" style="max-width: 1100px">
        <div class="number-item">
            <h1 id="one"></h1>
            <p>红包总金额</p>
        </div>
        <div class="number-item">
            <h1 id="tow"></h1>
            <p>红包总个数</p>
        </div>
        <div class="number-item">
            <h1 id="son"></h1>
            <p>已领取个数</p>
        </div>
    </div>
    <table class="layui-table">
        <colgroup>
            <col width="25%">
            <col width="25%">
            <col width="25%">
            <col width="25%">
        </colgroup>
        <thead>
        <tr>
            <th>客户名称</th>
            <th>客户类型</th>
            <th>领取时间</th>
            <th>领取金额</th>
        </tr>
        </thead>
        <tbody id="trss">
        
        </tbody>
    </table>
</div>

<script src="/red/lib/jquery-3.1.0.min.js"></script>
<script src="/red/lib/layui.js"></script>
<script src="/js/ajax.js"></script>
<script type="text/javascript">
    $('.navigation_1').click(function(){
        $('.nav_1').show();
        $('.nav_2').hide();
        $('.nav_3').hide();
        $('.nav_4').hide();
        $('.navigation_1').addClass('public_title_active');
        $('.navigation_2').removeClass('public_title_active');
        $('.navigation_3').removeClass('public_title_active');
        $('.navigation_4').removeClass('public_title_active');
        $('.public_buttonSearch_container').css('display','flex');
    })
    $('.navigation_2').click(function(){
        $('.nav_1').hide();
        $('.nav_2').show();
        $('.nav_3').hide();
        $('.nav_4').hide();
        $('.navigation_1').removeClass('public_title_active');
        $('.navigation_2').addClass('public_title_active');
        $('.navigation_3').removeClass('public_title_active');
        $('.navigation_4').removeClass('public_title_active');
        $('.public_buttonSearch_container').css('display','none');
    })
    $('.navigation_3').click(function(){
        $('.nav_1').hide();
        $('.nav_2').hide();
        $('.nav_3').show();
        $('.nav_4').hide();
        $('.navigation_1').removeClass('public_title_active');
        $('.navigation_2').removeClass('public_title_active');
        $('.navigation_3').addClass('public_title_active');
        $('.navigation_4').removeClass('public_title_active');
        $('.public_buttonSearch_container').css('display','none');
    })
     $('.navigation_4').click(function(){
        $('.nav_1').hide();
        $('.nav_2').hide();
        $('.nav_3').hide();
        $('.nav_4').show();
        $('.navigation_1').removeClass('public_title_active');
        $('.navigation_2').removeClass('public_title_active');
        $('.navigation_3').removeClass('public_title_active');
        $('.navigation_4').addClass('public_title_active');
        $('.public_buttonSearch_container').css('display','none');
    })
</script>
<script>
    $("#update_confing ").click(function () {
        var mchid = $("#mchid").val();
        var appid = $("#appid").val();
        var appKey = $("#appKey").val();
        var apiKey = $("#apiKey").val();
        var cert_one = $("#demospan1").val();
        var cert_tow = $("#demospan2").val();
        if(mchid=="" || appid=="" || appKey=="" || apiKey=="" || cert_one=="" || cert_tow==""){
            tusi("必填项不能为空");
            return false;
        }
        myAjaxPost(false, true, 'update_confing.html', { mchid:mchid,appid:appid,appKey:appKey,apiKey:apiKey,cert_one:cert_one,cert_tow:cert_tow}, function (resp) {
            tusi(resp.msg);
        })
    })
    
    $(".tab-nav span").click(function () {
        var index = $(this).index();
        $(".tab-body").children().eq(index).show().siblings().hide()
        $(".tab-body2").children().eq(index).show().siblings().hide()
        $(this).addClass('active').siblings().removeClass('active')
    })
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#time',
            range:true
        });
    });
    layui.use('layer', function () {
        var layer = layui.layer;

        $(".showmoeny").click(function () {
            layer.open({
                area: '540px',
                type: 1,
                title: '创建红包模板',
                content: $('#money') //这里content是一个普通的String
            });
        })
         $("#but").click(function () {
            layer.open({
                area: '540px',
                type: 1,
                title: '选择员工列表',
                content: $('#butyg') //这里content是一个普通的String
            });
        })
        $(".showuser").click(function () {
            layer.open({
                area: '540px',
                type: 1,
                title: '可用员工范围',
                content: $('#user') //这里content是一个普通的String
            });
        })
        $(".showline").click(function () {
            layer.open({
                area: '540px',
                type: 1,
                title: '红包限额',
                content: $('#line') //这里content是一个普通的String
            });
        })
    });
    layui.use('form', function () {
        var form = layui.form;
    });
    layui.use('upload', function () {
        var $ = layui.jquery
            , upload = layui.upload;
    });
    function uploads(id) {
        $("#" + id).trigger("click");
        openuploads(id);
    }

        function openuploads(id) {
        $("#" + id).change(function () {
            var formdata = new FormData();
            formdata.append('file', $("#" + id)[0].files[0]); //获取图片信息
            formdata.append('ordernumber', id); //
            $.ajax({
                url: "upload_file.html",
                type: 'post',
                data: formdata,
                cache: false,
                dataType: 'json',
                processData: false,
                contentType: false,
                success: function (e) {
                    if (e.status == "success") {
                        layer.msg(e.msg, '');
                        var data = e.data.filePath;
                        $("#demo1s").attr('src',data);
                        $("#demo2s").attr('value',data);
                    } else {
                        layer.msg(e.msg, '');
                    }
                }
            });
        });
    }

    function sab(e) {
        $('.table-select').children().eq($(e).val()).show().siblings().hide()
    }
    function ting(id){
        myAjaxPost(false, true, 'ting.html', { id:id}, function (resp) {
            if(resp.status == 'success'){
                alert(resp.msg);
                history.go(0);
            }else{
                alert(resp.msg);
            }
        });
    }
    function uphb(id){
        myAjaxPost(false, true, 'uphb.html', { id:id}, function (resp) {
            console.log(resp);
            if(resp.status == 'success'){
                $("#prices").attr('value',resp.data[0]);
                $("#names").attr('value',resp.data[1]);
                $("#writess").attr('value',resp.data[2]);
                $("#demo1").attr('src',resp.data[3]);
                $("#demo2").attr('value',resp.data[3]);
                $("#ids").attr('value',resp.data[4]);
            }
        });
        layer.open({
            area: '540px',
            type: 1,
            title: '修改红包模板页面',
            content: $('#moneys') //这里content是一个普通的String
        });
    }
    function dehb(id){
        myAjaxPost(false, true, 'dehb.html', { id:id}, function (resp) {
            if(resp.status == 'success'){
                alert(resp.msg);
                history.go(0);
            }else{
                alert(resp.msg);
            }
        });
    }

    function checks(id){
        myAjaxPost(false, true, 'checks.html', { id:id}, function (resp) {
            if(resp.status == 'success'){
                alert(resp.msg);
                history.go(0);
            }else{
                alert(resp.msg);
            }
        });
    }
    function check(){
        var checkboxs = document.getElementsByName("test");
        var check_val = [];
        for(k in checkboxs){
            if(checkboxs[k].checked){
                check_val.push(checkboxs[k].value);
            }
        }

        // alert(check_val);return false;
        myAjaxPost(false, true, 'check.html', { check_val:check_val}, function (resp) {
            if(resp.status == 'success'){
                alert(resp.msg);
                history.go(0);
            }else{
                alert(resp.msg);
            }
        });
    }
    function select_limit(id){
        var usernames = $("#usernames_"+id).val();
        myAjaxPost(false, true, 'select_limit.html', { usernames:usernames,id:id}, function (resp) {
            if(resp.status == 'success'){
                layer.msg(resp.msg);
            }else{
                layer.msg(resp.msg);
            }
        });
    }

    function showinfo(id){
        myAjaxPost(false, true, 'showinfo.html', { id:id}, function (resp) {
            var data_one = resp.data[0];
            var data_tow = resp.data[1];
            var url = resp.data[2];
            var str = "";
            data_one.forEach(function(datas) {
              str +="<tr>";
              str +="<td>";
              str +="<div class='tx-temp'>";
              if(datas.user.name){
                  str +="<img src='"+datas.user.avatar+"'>";
                  str +="<p>"+datas.user.name+"</p>";
              }else{
                  str +="<img src='"+url+"'>";
                  str +="<p>非企业客户</p>";
              }
              str +="</div>";
              str +="</td>";
              str +="<td>普通用户</td>";
              str +="<td>"+datas.times+"</td>";
              str +="<td>"+datas.price+"</td>";
              str +="</tr>";
        });
        document.getElementById('trss').innerHTML = str;
        document.getElementById('one').innerHTML = data_tow.price;
        document.getElementById('tow').innerHTML = data_tow.number;
        document.getElementById('son').innerHTML = data_one.length;
    });
     layer.open({
        area: '740px',
        type: 1,
        title: '红包领取详情',
        content: $('#info') //这里content是一个普通的String
    });
}

function customer_info(id){
    location.href='customer_info-'+id+'.html';
}
</script>
<script type="text/javascript">
        $('.public_tipSetting_contaienr svg').click(function(){
            $('.public_tipSetting_contaienr').hide();
        })
        layui.use('form', function(){
          var form = layui.form;
            
          //监听提交
          // form.on('submit(formDemo)', function(data){
          //   layer.msg(JSON.stringify(data.field));
          //   return false;
          // });
          form.render('select');
          
          form.on('select(type)', function(data){
            location.href="quick_reply.html?type="+data.value+"&name="+$('#name').val();
          });
        });
        function searchName(){
            location.href="quick_reply.html?name="+$('#name').val()+"&type="+$('#type').val();
        }
        function del_quick_reply(id){
            if(confirm('确定删除吗？')){
                myAjaxPost(false, true, 'del_quick_reply.html', { id:id}, function (resp) {
                    if (resp.status == 'success') {
                        tusi(resp.msg);
                        setTimeout(function(){
                            location.reload();
                        },500);
                    }else{
                        alert(resp.msg);
                    }
                });
            }
        }
    </script>
    <script type="text/javascript">
        function copyToClip(content, message) {
            var aux = document.createElement("input"); 
            aux.setAttribute("value", content); 
            document.body.appendChild(aux); 
            aux.select();
            document.execCommand("copy"); 
            document.body.removeChild(aux);
            if (message == null) {
                layer.msg("复制成功");
            } else{
                layer.msg(message);
            }
        }
    </script>

<script type="text/javascript">
    $(document).on("change","[name='testone']",function(){
        var price = $('#price_one').val();
        var number = $('#number_one').val();
        var username = $('#soukh').val();
        myAjaxPost(false, true, 'sou_index.html', { username:username,name:$("#testone").val(),price:price,number:number}, function (resp) {
            if (resp.status == 'success') {
                var str = "";
                var strs = "";
                var data_one = resp.data[0];
                var data_tow = resp.data[1];
                data_one.forEach(function(datas) {
                    if(datas.sy_number==0){
                        var num = '已领取';
                    }else{
                        num = '未领取';
                    }
                  str +="<tr>";
                  str +="<td>"+datas.price+"</td>";
                  str +="<td>";
                  str +="<div class='tx-temp'>";
                  str +="<img src='"+datas.user.avatar+"'>";
                  str +="<p>"+datas.user.name+"</p>";
                  str +="</div>";
                  str +="</td>";
                  str +="<td>"+datas.times+"</td>";
                  str +="<td>";
                  str +="<div class='tx-temp'>";
                  if(num == '未领取'){
                    str +="暂无领取记录";
                  }else{
                    str +="<img src='"+datas.list.avatar+"'>";
                    str +="<p>"+datas.list.name+"</p>";
                  }
                  str +="</div>";
                  str +="</td>";
                  str +="<td>"+num+"</td>";
                  if(num == '未领取'){
                    str +="<td>--</td>";
                  }else{
                    str +="<td>"+datas.list_times+"</td>";
                  }
                  str +="<td style='text-align: right'>";
                  str +="<span class='href' onclick='customer_info("+datas.list.id+")'>客户详情</span>";
                  str +="</td>";
                  str +="</tr>";
                });
                data_tow.forEach(function(datas) {
                    if(datas.sy_number==0){
                        var nums = '已领取完';
                    }else{
                        nums = '领取进行中';
                    }
                strs +="<tr>";;   
                strs +="<td>"+datas.price+"</td>";
                strs +="<td>";
                strs +="<div class='tx-temp'>";
                strs +="<img src='"+datas.user.avatar+"'>";
                strs +="<p>"+datas.user.name+"</p>";
                strs +="</div>";
                strs +="</td>";
                strs +="<td>"+datas.times+"</td>";
                strs +="<td>"+datas.sy_number+"/"+datas.number+"</td>";
                strs +="<td>"+nums+"</td>";
                strs +="<td style='text-align: right'>";
                strs +="<span class='href' onclick='showinfo("+datas.id+")'>领取详情</span>";
                strs +="<span class='href'>客户群详情</span>";
                strs +="</td>";
                strs +="</tr>";
                });
                document.getElementById('trssse').innerHTML = str;
                document.getElementById('trssses').innerHTML = strs;
            }else{
                alert(resp.msg);
            }
        });
    })
    
    function falses() {
        $("#filkes").trigger("click");
        openuploadstow();
    }
    
        function openuploadstow() {
        $("#filkes").change(function () {
            var formdata = new FormData();
            formdata.append('file', $("#filkes")[0].files[0]); //获取file信息
            $.ajax({
                url: "add_file.html",
                type: 'post',
                data: formdata,
                cache: false,
                dataType: 'json',
                processData: false,
                contentType: false,
                success: function (e) {
                    if (e.status == "success") {
                        layer.msg(e.msg, '');
                        var data = e.data.filePath;
                        $("#demospan1").attr('value',data);
                    } else {
                        layer.msg(e.msg, '');
                    }
                }
            });
        });
    }
    
    function falsesone() {
        $("#filkeone").trigger("click");
        openuploadsone();
    }
    
        function openuploadsone() {
        $("#filkeone").change(function () {
            var formdata = new FormData();
            formdata.append('file', $("#filkeone")[0].files[0]); //获取file信息
            $.ajax({
                url: "add_file.html",
                type: 'post',
                data: formdata,
                cache: false,
                dataType: 'json',
                processData: false,
                contentType: false,
                success: function (e) {
                    if (e.status == "success") {
                        layer.msg(e.msg, '');
                        var data = e.data.filePath;
                        $("#demospan2").attr('value',data);
                    } else {
                        layer.msg(e.msg, '');
                    }
                }
            });
        });
    }
       function chong(){
            window.location.href = window.location.href; 
       }
    function blers(){
        var time = $('#time').val();
        myAjaxPost(false, true, 'sou_index.html', { time:time}, function (resp) {
            if (resp.status == 'success') {
                var str = "";
                var strs = "";
                var data_one = resp.data[0];
                var data_tow = resp.data[1];
                data_one.forEach(function(datas) {
                    if(datas.sy_number==0){
                        var num = '已领取';
                    }else{
                        num = '未领取';
                    }
                  str +="<tr>";
                  str +="<td>"+datas.price+"</td>";
                  str +="<td>";
                  str +="<div class='tx-temp'>";
                  str +="<img src='"+datas.user.avatar+"'>";
                  str +="<p>"+datas.user.name+"</p>";
                  str +="</div>";
                  str +="</td>";
                  str +="<td>"+datas.times+"</td>";
                  str +="<td>";
                  str +="<div class='tx-temp'>";
                  if(num == '未领取'){
                    str +="暂无领取记录";
                  }else{
                    str +="<img src='"+datas.list.avatar+"'>";
                    str +="<p>"+datas.list.name+"</p>";
                  }
                  str +="</div>";
                  str +="</td>";
                  str +="<td>"+num+"</td>";
                  if(num == '未领取'){
                    str +="<td>--</td>";
                  }else{
                    str +="<td>"+datas.list_times+"</td>";
                  }
                  str +="<td style='text-align: right'>";
                  str +="<span class='href' onclick='customer_info("+datas.list.id+")'>客户详情</span>";
                  str +="</td>";
                  str +="</tr>";
                });
                data_tow.forEach(function(datas) {
                    if(datas.sy_number==0){
                        var nums = '已领取完';
                    }else{
                        nums = '领取进行中';
                    }
                strs +="<tr>";;   
                strs +="<td>"+datas.price+"</td>";
                strs +="<td>";
                strs +="<div class='tx-temp'>";
                strs +="<img src='"+datas.user.avatar+"'>";
                strs +="<p>"+datas.user.name+"</p>";
                strs +="</div>";
                strs +="</td>";
                strs +="<td>"+datas.times+"</td>";
                strs +="<td>"+datas.sy_number+"/"+datas.number+"</td>";
                strs +="<td>"+nums+"</td>";
                strs +="<td style='text-align: right'>";
                strs +="<span class='href' onclick='showinfo("+datas.id+")'>领取详情</span>";
                strs +="<span class='href'>客户群详情</span>";
                strs +="</td>";
                strs +="</tr>";
                });
                document.getElementById('trssse').innerHTML = str;
                document.getElementById('trssses').innerHTML = strs;
            }else{
                alert(resp.msg);
            }
        });
    }
</script>
</body>
</html>